import 'package:flutter/material.dart';
import 'package:flutter_enjoy/pages/home/index.dart';
import 'package:flutter_enjoy/pages/mine/index.dart';

class TabsPage extends StatefulWidget {
  const TabsPage({super.key});

  @override
  // ignore: library_private_types_in_public_api
  _TabsPageState createState() => _TabsPageState();
}

class _TabsPageState extends State<TabsPage> {
  int _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _currentIndex,
        children: const [
          HomePage(),
          MinePage(),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        backgroundColor: Colors.white,
        selectedItemColor: Color(0xff5592af),
        unselectedItemColor: Color(0xff434242),
        selectedFontSize: 12,
        unselectedFontSize: 12,
        currentIndex: _currentIndex,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: [
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/tabs/home_default.png',
                width: 24,
                height: 24,
              ),
              activeIcon: Image.asset(
                'assets/tabs/home_active.png',
                width: 24,
                height: 24,
              ),
              label: '首页'),
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/tabs/my_default.png',
                width: 24,
                height: 24,
              ),
              activeIcon: Image.asset(
                'assets/tabs/my_active.png',
                width: 24,
                height: 24,
              ),
              label: '我的'),
        ],
      ),
    );
  }
}
